﻿@{
    ViewData["Title"] = "日志列表";
    Layout = "~/Areas/Manager/Views/Shared/_Layout.cshtml";
}
<form asp-action="ExportList">
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">日志列表</div>
                    <div class="layui-card-body">
                        <div class="layui-form">
                            <div class="layui-row">
                                <div class="layui-form-item">
                                    <div class="layui-col-md2" style="padding-left:0">
                                        <select id="type" name="type">
                                            <option value="">==日志类型==</option>
                                            <option value="1">错误日志</option>
                                            <option value="2">操作日志</option>
                                        </select>
                                    </div>
                                    <div class="layui-col-md2">
                                        <input type="text" id="startTime" name="startTime" placeholder="开始时间" autocomplete="off" class="layui-input">
                                    </div>
                                    <div class="layui-col-md2">
                                        <input type="text" id="endTime" name="endTime" placeholder="结束时间" autocomplete="off" class="layui-input">
                                    </div>
                                    <div class="layui-col-md3">
                                        <div class="input-group">
                                            <input type="text" id="keyWords" name="keyWords" placeholder="请输入查找的内容" autocomplete="off" class="layui-input">
                                            <span class="input-group-btn">
                                                <i class="layui-btn" id="search">
                                                    <i class="layui-icon layui-icon-search"></i>
                                                </i>
                                            </span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-btn-container">
                                <div class="layui-btn-group">
                                    <button type="submit" class="layui-btn layui-btn-sm layui-bg-green " id="export"><i class="layui-icon">&#xe654;</i>导出</button>
                                    <button type="button" id="deleteAll" class="layui-btn layui-btn-sm layui-bg-red"><i class="layui-icon">&#xe640;</i>删除</button>
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <table class="layui-table" lay-data="{ page:true, id:'list'}" lay-filter="list">
                                <thead>
                                    <tr>
                                        <th lay-data="{checkbox:true, fixed: true}"></th>
                                        <th lay-data="{field:'logId',width:87}">ID</th>
                                        <th lay-data="{field:'title'}">标题</th>
                                        <th lay-data="{field:'detail'}">详细</th>
                                        <th lay-data="{field:'userName'}">用户名</th>
                                        <th lay-data="{field:'userId',width:73}">userId</th>
                                        <th lay-data="{field:'type',templet: '#buttonTpl'}">类型</th>
                                        <th lay-data="{field:'ipAddress'}">ip</th>
                                        <th lay-data="{field:'url',width:325}">url</th>
                                        <th lay-data="{field:'createDate',width:165}">创建时间</th>
                                    </tr>
                                </thead>
                            </table>
                            <script type="text/html" id="buttonTpl">
                                {{#  if(d.type==1){ }}
                                <span class="layui-badge layui-bg-red">错误日志</span>
                                {{#  } else { }}
                                <span class="layui-badge layui-bg-blue">操作日志</span>
                                {{#  } }}
                            </script>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
@section scriptsfeet
    {
    <script type="text/javascript">
        layui.config({
            base: '/layuiadmin/' //自定义模块路径
        }).use(['sykjwh','laydate'], function () {
            var sykjwh = layui.sykjwh, $ = layui.jquery,laydate = layui.laydate;

            //绑定数据
            sykjwh.dataBind('@Url.Action("list", "log", new { area = Constant.AREAMANAGER })');

            //批量删除
            $("#deleteAll").click(function () {
                sykjwh.batOperate('@Url.Action("deleteall", "log", new { area = Constant.AREAMANAGER })', 'logId');
            });

            //搜索
            $("#search").click(function () {
                //绑定数据
                sykjwh.dataBind('@Url.Action("list", "log", new { area = Constant.AREAMANAGER })', {
                    keyWords: $.trim($("#keyWords").val()),
                    type: $.trim($("#type").val()),
                    startTime: $.trim($("#startTime").val()),
                    endTime: $.trim($("#endTime").val()),
                });
            });

            //执行一个laydate 开始实例
            laydate.render({
                elem: '#startTime',
                type: 'datetime',//日期格式
                format: 'yyyy/MM/dd HH:mm:ss',  //时间格式  
            });

            //执行一个laydate 结束实例
            laydate.render({
                elem: '#endTime',
                type: 'datetime',//日期格式
                format: 'yyyy/MM/dd HH:mm:ss',  //时间格式  
            });
        });
    </script>
}